package com.meituan.sqt.mock.infrastructure.persistence.mysql.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.meituan.sqt.mock.domain.enums.OrderStatusEnum;
import com.meituan.sqt.mock.domain.enums.PayStatusEnum;
import lombok.Builder;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

/**
 * @author: chenzhenfeng@meituan.com
 * @date: 2023/1/30 16:43
 * @description:
 */
@Data
@Builder
@TableName("type_b_order_info")
public class TypeBOrderInfoPo {
    private Long orderId;
    private Long sqtBizOrderId;
    private BigDecimal tradeAmount;
    private BigDecimal serviceFeeAmount;
    private String goodsName;
    private String notifyUrl;
    private String returnUrl;
    private Integer businessType;
    private Integer orderStatus;
    private String extInfo;
    private Date gmtCreated;
    private Date gmtModified;

    /**
     * 判断订单是否完成过支付
     * @return
     */
    public boolean isPayed() {
        // 仅示例，客户平台根据实际状态设计进行判断，订单状态为已支付、已完成、已退款均认为是支付成功过
        if (Objects.nonNull(orderStatus) && orderStatus >= OrderStatusEnum.PAYED.getCode()) {
            return true;
        }
        return false;
    }
}
